home *** CD-ROM | disk | FTP | other *** search
Text File | 1996-08-16 | 2.6 KB | 104 lines | [TEXT/MPS ] |
- //========================================================================================
- //
- // File: FWSOMPtr.h
- // Release Version: $ ODF 1 $
- //
- // Copyright: (c) 1993 - 1996 by Apple Computer, Inc., all rights reserved.
- //
- //========================================================================================
-
- #ifndef FWSOMPTR_H
- #define FWSOMPTR_H
-
- #ifndef FWEXCLIB_H
- #include "FWExcLib.h"
- #endif
-
- //========================================================================================
- // TSOMPtr
- // This class encapsulates an auto-destructing pointer to a SOM object. This is
- // presumed to be the only pointer to that SOM object; assignment of another TRep*
- // deletes the current one.
- //========================================================================================
-
- template<class TRep>
- class FW_TSOMPtr
- {
- public:
- FW_DECLARE_AUTO(FW_TSOMPtr<TRep>)
- ~FW_TSOMPtr(); // dtors of auto objects must be public
-
- protected:
- FW_TSOMPtr();
- FW_TSOMPtr(Environment *ev, TRep* rep);
-
- public:
- TRep* operator->() const
- { return fRep; }
-
- operator TRep*() const
- { return fRep; }
-
- TRep* GetRep() const
- { return fRep; }
-
- void SetRep(Environment *ev, TRep* rep);
-
- private:
- TRep* fRep;
-
- private:
- // There are no copy constructors or assignment operators allowed.
- FW_TSOMPtr(const FW_TSOMPtr<TRep>& other);
- void operator=(const FW_TSOMPtr<TRep>& other);
- };
-
-
-
- //========================================================================================
- // FW_TCountedSOMPtr
- // This class encapsulates a counted pointer to a SOM object.
- //========================================================================================
-
- template<class TRep>
- class FW_TCountedSOMPtr
- {
- public:
- FW_DECLARE_AUTO(FW_TCountedSOMPtr<TRep>)
- ~FW_TCountedSOMPtr(); // dtors of auto objects must be public
-
- protected:
- FW_TCountedSOMPtr();
-
- FW_TCountedSOMPtr(const FW_TCountedSOMPtr<TRep>& other);
- FW_TCountedSOMPtr(Environment *ev, const FW_TCountedSOMPtr<TRep>& other);
- void operator=(const FW_TCountedSOMPtr<TRep>& other)
- { operator=(other.fRep); }
-
- FW_TCountedSOMPtr(Environment *ev, TRep* other);
- void operator=(TRep* other);
-
- public:
- FW_Boolean IsSameRepAs(const FW_TCountedSOMPtr<TRep>& other) const
- { return IsSameRepAs(other.fRep); }
-
- FW_Boolean IsSameRepAs(const TRep* other) const
- { return fRep == other; }
-
- TRep* operator->() const
- { return fRep; }
-
- operator TRep*() const
- { return fRep; }
-
- TRep* GetRep() const
- { return fRep; }
-
- void SetRep(Environment *ev, TRep* rep);
-
- private:
- TRep* fRep;
- };
-
- #endif
-